package com.sgb.kjwl.viewmodel.pick;

import android.text.TextUtils;

import com.sgb.kjwl.AppConstant;
import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.model.entity.BiddingEntity;
import com.sgb.kjwl.model.entity.ProListEntity;
import com.sgb.kjwl.model.entity.pick.PreNoticeItemEntity;
import com.sgb.kjwl.model.entity.pick.TenderAllListNewEntity;
import com.sgb.kjwl.repository.PickRepertory;
import com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity;
import com.sgb.kjwl.view.ui.fragment.pick.PickListsFragment;
import com.sgb.zhaocai.base.BaseApi;
import com.sgb.zhaocai.entity.DemandForecastListBean;
import com.sgb.zhaocai.entity.DemandForecastListEntity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.base.model.entity.H5ReEntity;
import com.swgk.core.base.model.entity.ListResponse;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.util.MLog;
import com.swgk.core.util.MToast;
import com.swgk.core.util.PickSelectEntity;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.areapopup.AddressEntity;
import com.swgk.core.view.selection.CommonPopEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class PickListsFragmentModel extends BaseViewModel {

    private PickListsFragment pickListsFragment;
    private PickRepertory repertory;
    private HashMap map;
    private int page = 1;
    private int pageSize = 10;
    private PickSelectEntity mAll;
    private String longitude;
    private String latitude;
    private boolean isLastPage;

    public PickListsFragmentModel(PickListsFragment pickListsFragment, PickRepertory repertory) {
        this.pickListsFragment = pickListsFragment;
        this.repertory = repertory;

        mAll = new PickSelectEntity();
        mAll.setNo("");
        mAll.setProjectscale("全部");
    }

    //招标大厅-全部
    public void findTenderingHomeEsPage(int page, String type, String goodsType, String areacode, String city, String keyword, String sortType, String dataSources) {

        map = new HashMap();
        if ("0".equals(type)) {
            type = "";
        }
        map.put("type", type);
        map.put("goodsTypeNo", goodsType);
        map.put("province", areacode);
        map.put("city", city);

        map.put("queryPosition", 3);
        map.put("current", page);
        map.put("limit", pageSize);
        map.put("sortMethod",sortType);
        map.put("dataSources",dataSources);
        map.put("keyword",keyword);

        if (pickListsFragment.getActivity() != null && !pickListsFragment.getActivity().isDestroyed() && !pickListsFragment.getActivity().isFinishing()) {
            DialogHelper.showProgressDialog(pickListsFragment.getActivity(), null, "加载中", 0, true, null).setCanceledOnTouchOutside(false);
        }
        APIManager.getInstance().getPickAPI().queryHomeEsPage(map).enqueue(new Callback<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>>() {
            @Override
            public void onResponse(Call<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>> call, Response<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null)
                    return;
                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.getAllData(response.body().getData().getList());
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), response.body().getMsg());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    //招标公告-全部
    public void findNoticeHomeEsPage(int page,String type, String goodsType, String areacode, String city, String keyword, String sortType, String dataSources) {

        map = new HashMap();

        if ("0".equals(type)) {
            type = "";
        }
        map.put("type", type);
        map.put("goodsTypeNo", goodsType);
        map.put("province", areacode);
        map.put("city", city);

        map.put("queryPosition", 5);
        map.put("current", page);
        map.put("limit", pageSize);
        map.put("sortMethod",sortType);
        map.put("dataSources",dataSources);
        map.put("keyword",keyword);

        if (pickListsFragment.getActivity() != null && !pickListsFragment.getActivity().isDestroyed() && !pickListsFragment.getActivity().isFinishing()) {
            DialogHelper.showProgressDialog(pickListsFragment.getActivity(), null, "加载中", 0, true, null).setCanceledOnTouchOutside(false);
        }
        APIManager.getInstance().getPickAPI().queryHomeEsPage(map).enqueue(new Callback<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>>() {
            @Override
            public void onResponse(Call<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>> call, Response<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null)
                    return;
                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.getAllData(response.body().getData().getList());
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), response.body().getMsg());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    //招标大厅-招标公告
    public void getHallList(int page,String cityNo, String typeNo, String moneyNo, String statusNo, String search, String modeType, String areaCode, String goodsType,String sortMethod,String time,String startTime,String bidMethodType) {

        map = new HashMap();
        if (!"".equals(areaCode) && areaCode != null)
            map.put("province", areaCode);
        if (!"".equals(cityNo) && cityNo != null)
            map.put("city", cityNo);
        if (!TextUtils.isEmpty(goodsType)) {
            map.put("goodsTypeNo", goodsType); // 清单分类类型
        }

        if ("0".equals(typeNo)) {
            typeNo = "";
        }
        map.put("type", typeNo); // 招标类型
        map.put("qualificationWay", modeType);
        map.put("sortMethod", Integer.valueOf(sortMethod));
        map.put("queryPosition", 4);
        map.put("price", moneyNo);
        map.put("limit", pageSize);
        map.put("current", page);
        map.put("state", statusNo);
        map.put("biddingMethod",bidMethodType);
        map.put("keyword",search);
        if (!TextUtils.isEmpty(time))
            map.put("time", time);
        if (!TextUtils.isEmpty(startTime))
            map.put("startTime", startTime);

        if (pickListsFragment.getActivity() != null && !pickListsFragment.getActivity().isDestroyed() && !pickListsFragment.getActivity().isFinishing()) {
            DialogHelper.showProgressDialog(pickListsFragment.getActivity(), null, "加载中", 0, true, null).setCanceledOnTouchOutside(false);
        }
        APIManager.getInstance().getPickAPI().queryHomeEsPage(map).enqueue(new ICallBack<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<TenderAllListNewEntity>>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }
                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.showHallList(data.getData().getList());
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), data.getMsg());
                }
            }
        });

    }

    //招标公告-招标报名
    public void getHallBidingList(int page,String cityNo, String typeNo, String priceNo, String time, String search, String verticalType, String areaCode, String goodsType, String sortMethod,String bidMethodType) {
        map = new HashMap();
        if (!"".equals(areaCode) && areaCode != null)
            map.put("province", areaCode);
        if (!"".equals(cityNo) && cityNo != null)
            map.put("city", cityNo);
        if (!TextUtils.isEmpty(goodsType)) {
            map.put("goodsTypeNo", goodsType); // 清单分类类型
        }

        if ("0".equals(typeNo)) {
            typeNo = "";
        }
        map.put("type", typeNo); // 招标类型
        map.put("time", time); // 报名结束时间
        map.put("qualificationWay", verticalType);
        map.put("sortMethod", Integer.valueOf(sortMethod));
        map.put("queryPosition", 6);
        map.put("price", priceNo);
        map.put("limit", pageSize);
        map.put("current", page);
        map.put("biddingMethod",bidMethodType);
        map.put("keyword",search);

        if (pickListsFragment.getActivity() != null && !pickListsFragment.getActivity().isDestroyed() && !pickListsFragment.getActivity().isFinishing()) {
            DialogHelper.showProgressDialog(pickListsFragment.getActivity(), null, "加载中", 0, true, null).setCanceledOnTouchOutside(false);
        }
        APIManager.getInstance().getPickAPI().queryHomeEsPage(map).enqueue(new ICallBack<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<TenderAllListNewEntity>>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.showHallList(data.getData().getList());
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), data.getMsg());
                }
            }
        });

    }

    //直接竞价
    public void getBiddingList(int page,String cityNo, String typeNo, String statusNo, String price, String search, String provinceNo, String goodsType, String sortMethod, String comNo, String fromWhere) {
        map = new HashMap();
        if (!"".equals(provinceNo) && provinceNo != null)
            map.put("province", provinceNo);
        if (!"".equals(cityNo) && cityNo != null)
            map.put("city", cityNo);
        map.put("limit", pageSize);
        map.put("keyword", search);
        map.put("current", page);
        map.put("state", statusNo);
        map.put("comNo", comNo);
        if (!"".equals(typeNo) && typeNo != null)
            map.put("type", typeNo);
        if (!"".equals(price) && price != null)
            map.put("price", price);
        if (!TextUtils.isEmpty(goodsType)) {
            map.put("goodsTypeNo", goodsType);
        }
        map.put("sortMethod", Integer.valueOf(sortMethod));
        if ("1".equals(fromWhere)) {     //招标大厅
            map.put("queryPosition", "8");
        } else if ("2".equals(fromWhere)) {  //招标公告
            map.put("queryPosition", "9");
        }

        DialogHelper.showProgressDialog2(pickListsFragment.getActivity(), null, "加载中", 0, true, null, false);
        APIManager.getInstance().getPickAPI().queryHomeEsPage(map).enqueue(new ICallBack<BaseEntity<ListResponse<List<TenderAllListNewEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<TenderAllListNewEntity>>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.showBiddingList(data.getData().getList());
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    //招标预告
    public void getPreBiddingList(int page,String name, String type, String goodsType, String biddingMethod, String verticalType, String applyStartTime, String price, String areacode, String city, String sortMethod, String comNo) {
        DialogHelper.showProgressDialog2(pickListsFragment.getActivity(), null, "获取信息中...", 0, false, null, false);
        map = new HashMap();
        map.put("limit", pageSize);
        map.put("page", page);
        if (!TextUtils.isEmpty(name)) {
            map.put("name", name);
        }
        if (!TextUtils.isEmpty(biddingMethod)) {
            map.put("biddingMethod", biddingMethod);
        }
        map.put("verticalType", verticalType);
        if ("0".equals(type)) {
            type = "";
        }
        map.put("type", type);
        map.put("goodsType", goodsType);
        map.put("applyStartTime", applyStartTime);
        map.put("price", price);
        map.put("sortMethod", sortMethod);
        map.put("comNo", comNo);
        if (!TextUtils.isEmpty(areacode)) {
            map.put("areacode", areacode);
        }
        if (!TextUtils.isEmpty(city)) {
            map.put("city", city);
        }
        APIManager.getInstance().getPickAPI().getPreBiddingList(map).enqueue(new Callback<BaseEntity<ProListEntity<List<PreNoticeItemEntity>>>>() {
            @Override
            public void onResponse(Call<BaseEntity<ProListEntity<List<PreNoticeItemEntity>>>> call, Response<BaseEntity<ProListEntity<List<PreNoticeItemEntity>>>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null) return;
                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.showPreBiddingList(response.body().getData().getList());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<ProListEntity<List<PreNoticeItemEntity>>>> call, Throwable t) {
                MLog.d(AppConstant.API_LOG, t.getMessage());
            }
        });
    }

    //需求预告
    public void getMaterialHomeList(String pos, DemandForecastListBean requestBean) {
        DialogHelper.showProgressDialog(pickListsFragment.getActivity(), null, "数据加载中", 0, true, null).setCanceledOnTouchOutside(false);
        Call<BaseEntity<ListResponse<List<DemandForecastListEntity>>>> call = null;
        switch (pos) {
            case "3":
                call = APIManager.getInstance().getPickAPI().getMaterialHomeList(requestBean);
                break;
            case "1":
                call = APIManager.getInstance().getPickAPI().getMechanicalHomeList(requestBean);
                break;
            case "5":
                call = APIManager.getInstance().getPickAPI().getEquipmentHomeList(requestBean);
                break;
            case "2":
                call = APIManager.getInstance().getPickAPI().getLaborHomeList(requestBean);
                break;
            case "4":
                call = APIManager.getInstance().getPickAPI().getSubcontractPlanHomeList(requestBean);
                break;
            default:
                call = APIManager.getInstance().getPickAPI().getMaterialHomeList(requestBean);
                break;
        }
        call.enqueue(new ICallBack<BaseEntity<ListResponse<List<DemandForecastListEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<DemandForecastListEntity>>> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getState().equals(BaseApi.RESPONSE_OK)) {
                    isLastPage = data.getData().getCurrentPage() >= data.getData().getTotal();
                    pickListsFragment.setDemandList(data.getData().getList(), isLastPage);
                } else {
                    MToast.showToast(pickListsFragment.getContext(), data.getMsg());
                }
            }
        });
    }

    public void tenderWayByType(String no, String fromWhere) {
        DialogHelper.showProgressDialog2(pickListsFragment.getActivity(), null, "加载中", 0, true, null, false);
        map = new HashMap();
        map.put("no", no);
        map.put("isMap", false);
        map.put("tab", fromWhere);
        APIManager.getInstance().getPickAPI().tenderWayByType(map).enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setBidTypeData(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    public void getFilterStatusData() {
        Map map = new HashMap();
        map.put("areacode", repertory.getAreaCode());
        APIManager.getInstance().getPickAPI().getProjectStatus(map).enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {

            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setStatusDatas(data.getData());
                }
            }
        });
    }

    public void getTenderNewTypeList() {
        DialogHelper.showProgressDialog2(pickListsFragment.getContext(), null, "数据加载中...", 0, false, null, false);
        APIManager.getInstance().getPickAPI().getTenderNewTypeList().enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setTenderTypeDatas(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
            }
        });
    }

    public void getPickTimes() {
        APIManager.getInstance().getPickAPI().getPickTimes().enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setTimeDatas(data.getData());
                }
            }
        });
    }

    public void getPriceData() {
        APIManager.getInstance().getPickAPI().getProjectMoney().enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setPriceDatas(data.getData());
                }
            }
        });
    }

    public void getFilterTypeData() {
        APIManager.getInstance().getPickAPI().tenderNewTypeList().enqueue(new ICallBack<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PickSelectEntity>> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setTypeDatas(data.getData());
                }
            }
        });
    }

    public void getUrlSetting(String id) {
        DialogHelper.showProgressDialog2(pickListsFragment.getActivity(), null, "加载中", 0, true, null, false);
        APIManager.getInstance().getPickAPI().getUrlSetting("competitivePurchase").enqueue(new ICallBack<BaseEntity<H5ReEntity>>() {
            @Override
            public void onSuccess(BaseEntity<H5ReEntity> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    String url = data.getData().getUrl() + "?id=" + id;
                    String lng = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LONGITUDE_ID, "");
                    String lat = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LATITUDE_ID, "");
                    url = url + "&lng=" + lng + "&lat=" + lat;
                    MLog.d("api", "H5跳转链接  " + url);
                    pickListsFragment.getUrl(url, id);
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    public void getUrlSettingSj(String id) {
        APIManager.getInstance().getPickAPI().getUrlSetting("tenderdetails").enqueue(new ICallBack<BaseEntity<H5ReEntity>>() {
            @Override
            public void onSuccess(BaseEntity<H5ReEntity> data) {
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    String url = data.getData().getUrl() + "?id=" + id;
                    pickListsFragment.getUrl(url, id);
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    public void getProvinceData(int type) {
        DialogHelper.showProgressDialog2(pickListsFragment.getActivity(), null, "加载中", 0, true, null, false);
        APIManager.getInstance().getPickAPI().getAddressEntityCityList().enqueue(new ICallBack<BaseEntity<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>>>() {
            @Override
            public void onSuccess(BaseEntity<List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>>> data) {
                if (data != null && data.getData() != null && data.getData().size() > 0) {
                    List<PickSelectEntity> entities = new ArrayList<>();
                    for (AddressEntity<List<AddressEntity<List<AddressEntity>>>> datum : data.getData()) {
                        entities.add(new PickSelectEntity(datum.getNo(), datum.getSimpleName()));
                    }
                    entities.add(0, mAll);
                    pickListsFragment.setChooseItemData(type, entities);
                    pickListsFragment.setProvinceDatas(data.getData());
                }
            }
        });
    }

    public void getAddressCityData(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> scrData, String no, int type) {
        for (AddressEntity<List<AddressEntity<List<AddressEntity>>>> scrDatum : scrData) {
            if (scrDatum.getId().equals(no)) {
                List<AddressEntity<List<AddressEntity>>> children = scrDatum.getChildren();
                if (children != null && children.size() > 0) {
                    List<PickSelectEntity> entities = new ArrayList<>();
                    for (AddressEntity<List<AddressEntity>> child : children) {
                        entities.add(new PickSelectEntity(child.getNo(), child.getSimpleName()));
                    }
                    entities.add(0, mAll);
                    pickListsFragment.setChooseItemData(type, entities);
                }
            }
        }
    }

    public void getAddressCityDataDialog(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> scrData, String no) {
        for (AddressEntity<List<AddressEntity<List<AddressEntity>>>> scrDatum : scrData) {
            if (scrDatum.getId().equals(no)) {
                List<AddressEntity<List<AddressEntity>>> children = scrDatum.getChildren();
                if (children != null && children.size() > 0) {
                    List<PickSelectEntity> entities = new ArrayList<>();
                    for (AddressEntity<List<AddressEntity>> child : children) {
                        entities.add(new PickSelectEntity(child.getNo(), child.getSimpleName()));
                    }
                    entities.add(0, mAll);
                    pickListsFragment.setCityDatas(entities);
                }
            }
        }
    }

    //新增类型过滤接口
    public void getTenderGoodsCategoryAllList(String category) {
        DialogHelper.showProgressDialog2(pickListsFragment.getActivity(), null, "加载中", 0, true, null, false);
        map = new HashMap();
        map.put("type", category);
        APIManager.getInstance().getPickAPI().getTenderGoodsCategoryAllListNew(map).enqueue(new ICallBack<BaseEntity<List<CommonPopEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<CommonPopEntity>> data) {
                DialogHelper.dismissProgressDialog();
                if (data == null || data.getState() == null) {
                    return;
                }

                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setTenderGoodsCategoryAllList(data.getData());
                }
            }
        });
    }

    //综合排序
    public void getSortTypeData(String name) {
        String no = "";
        map = new HashMap();
        switch (name) {
//            case "招标报名":
//                no = "1";
//                break;
            case "招标预告":
                no = "2";
                break;
//            case "招标公告":
//                no = "3";
//                break;
            case "直接竞价":
                no = "9";
                break;
            case "需求预告":
                no = "6";
                break;
            case "招标公告":
            case "招标报名":
            case "招标形式":
                no = "8";
                break;
        }
        map.put("no",no);
        APIManager.getInstance().getPickAPI().getAllSortSelect(no).enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setSortDatas(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {

            }
        });
    }

    /**
     * 发布时间
     */
    public void getTime() {
        APIManager.getInstance().getPickAPI().getfindProjectTimeSelectNew().enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setTime(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {

            }
        });
    }

    //首页-招标大厅-需求预告列表详情页
    public void getWebH5(String id, String modelType) {
        longitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LONGITUDE_ID, "");
        latitude = SharedPreferenceUtil.getInstance().getString(SharedPreferenceUtil.LATITUDE_ID, "");
        if (TextUtils.isEmpty(longitude)) {
            longitude = "0";
        }
        if (TextUtils.isEmpty(latitude)) {
            latitude = "0";
        }
        DialogHelper.showProgressDialog(pickListsFragment.getActivity(), null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        APIManager.getInstance().getPickAPI().getUrlSetting("demandNoticeDetails").enqueue(new ICallBack<BaseEntity<H5ReEntity>>() {
            @Override
            public void onSuccess(BaseEntity<H5ReEntity> data) {
                if (data == null || data.getState() == null) {
                    return;
                }
                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    String webUrl = data.getData().getUrl() + "?id=" + id + "&localLat=" + latitude + "&localLng=" + longitude + "&type=" + modelType;
                    WebViewX5HostActivity.start(pickListsFragment.getActivity(), webUrl);
                } else {
                    MToast.showToast(pickListsFragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    //数据来源筛选框
    public void getDataSources() {
        APIManager.getInstance().getPickAPI().getDataSources().enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setDataSources(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {

            }
        });
    }

    //招标形式接口
    public void getBiddingMethod() {
        APIManager.getInstance().getPickAPI().getBiddingMethod().enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    pickListsFragment.setBidMethodDatas(response.body().getData());
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {

            }
        });
    }
}
